package 测试;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;

public class 全排列 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			ArrayList<String> permutation = Permutation(sc.next());
			// permutation.forEach((x) -> {
			// System.out.println(x);
			// });
			for (String x : permutation) {
				System.out.println(x);
			}
		}
		sc.close();
	}

	public static ArrayList<String> Permutation(String str) {
		ArrayList<String> al = new ArrayList<String>();
		if (str == null || str.length() == 0 || str.length() > 9)
			return al;
		ArrayList<String> sal = str2al(str);
		ArrayList<ArrayList<String>> Perm = calPerm(sal);
		for (int i = 0; i < Perm.size(); i++) {
			al.add(al2str(Perm.get(i)));
		}
		HashSet<String> hs = new HashSet<String>(al);
		ArrayList<String> res = new ArrayList<String>(hs);
		Collections.sort(res);
		return res;
	}

	public static void calPermRecursion(ArrayList<ArrayList<String>> tal, ArrayList<String> sal, int n) {
		if (n == sal.size()) {
			tal.add(new ArrayList<String>(sal));
		} else {
			for (int i = n; i < sal.size(); i++) {
				Collections.swap(sal, i, n);
				calPermRecursion(tal, sal, n + 1);
				Collections.swap(sal, i, n);
			}
		}
	}

	public static ArrayList<ArrayList<String>> calPerm(ArrayList<String> sal) {
		ArrayList<ArrayList<String>> tal = new ArrayList<ArrayList<String>>();
		calPermRecursion(tal, sal, 0);
		return tal;
	}

	public static ArrayList<String> str2al(String s) {
		ArrayList<String> al = new ArrayList<String>();
		for (int i = 0; i < s.length(); i++) {
			al.add(String.valueOf(s.charAt(i)));
		}
		return al;
	}

	public static String al2str(ArrayList<String> al) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < al.size(); i++) {
			sb.append(al.get(i));
		}
		return sb.toString();
	}
}
